package com.exam.scjp5.objectives.section_3;

import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;

public class ExampleDateFormat
{
    public static void main(String args[])
    {
        Date today = new Date();
        DateFormat dateFormats[] = new DateFormat[7];
        
        dateFormats[0] = DateFormat.getInstance();
        dateFormats[1] = DateFormat.getDateInstance(); // Default format is MEDIUM
        dateFormats[2] = DateFormat.getTimeInstance();
        dateFormats[3] = DateFormat.getDateInstance(DateFormat.SHORT);
        dateFormats[4] = DateFormat.getDateInstance(DateFormat.MEDIUM);
        dateFormats[5] = DateFormat.getDateInstance(DateFormat.LONG);
        dateFormats[6] = DateFormat.getDateInstance(DateFormat.FULL);
        
        for(DateFormat df : dateFormats)
            System.out.println(df.format(today));
        
        try
        {
            System.out.println(dateFormats[5].format(dateFormats[1].parse("9/14/10 9:53 AM")));
        }
        catch (ParseException e)
        {
            e.printStackTrace();
        }
                                
    }
}
